#include "functions.h"
#include "keypoints.h"
#include <sys/timeb.h>


int getMilliCount(){
    timeb tb;
    ftime(&tb);
    int nCount = tb.millitm + (tb.time & 0xfffff) * 1000;
    return nCount;
}

int getMilliSpan(int nTimeStart){
    int nSpan = getMilliCount() - nTimeStart;
    if(nSpan < 0)
        nSpan += 0x100000 * 1000;
    return nSpan;
}




float computeLeafSize (PointCloud<PointXYZ>::Ptr cloud,int nVoxelsRequired)
{
    PointXYZ min;
    PointXYZ max;
    //trova gli estremi della cloud
    getMinMax3D<PointXYZ>(*cloud,min,max);
    Eigen::Vector3f size=max.getVector3fMap()-min.getVector3fMap();
    float surface=size[0]*size[1];
    float leafSize= sqrt(2*surface/nVoxelsRequired);
    return leafSize;
}


